package lc;

public class Q746 {
    public int minCostClimbingStairs(int[] cost) {
        // dp算法即可
        int last = 0;// 倒数第一个
        int last2 = 0;// 倒数第二个
        for (int i = cost.length - 1; i >= 0; i--) {
            // 计算经过i时最小的
            int min = cost[i] + Math.min(last, last2);
            last = last2;
            last2 = min;
        }
        return Math.min(last, last2);

    }

    public static void main(String[] args) {
        final Q746 q746 = new Q746();
        final int i = q746.minCostClimbingStairs(new int[]{1, 100, 1, 1, 1, 100, 1, 1, 100, 1});
        System.out.println(i);
    }

}
